package com.ltxtiyu.video.interceptor;

import com.ltxtiyu.video.entity.Manager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    public static final Logger log = LoggerFactory.getLogger(LoginInterceptor.class);
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Manager loginUser = (Manager) request.getSession().getAttribute("loginUser");

        if(loginUser == null){
            log.info("管理员未登陆");
            response.sendRedirect("/page/login");
            return false;
        }else{

            return true;
        }

    }


}
